
package convertobject;

import java.util.ArrayList;
import java.util.List;

import doantotnghiep.model.PurchaseOrder;
import doantotnghiep.modelDTO.PurchaseOrderDTO;

public class Convert {
	
	public static List<PurchaseOrderDTO> convertToPurchaseOrderDTO(List<PurchaseOrder> obj)
	{
		List<PurchaseOrder> purchases = obj;
		List<PurchaseOrderDTO> purchaseDTOs = new ArrayList<PurchaseOrderDTO>(); 
		for(PurchaseOrder c: purchases){
			PurchaseOrderDTO purchaseOrderDTO = new PurchaseOrderDTO();
			purchaseOrderDTO.setOrderID(c.getOrderID());
			purchaseOrderDTO.setDeliveryDate(c.getDeliveryDate());
			purchaseOrderDTO.setDeliveryLocation(c.getDeliveryLocation());
			purchaseOrderDTO.setOrderedDate(c.getOrderedDate());
			
			purchaseOrderDTO.setCustomerName(c.getCustomer().getFullName());
			purchaseOrderDTO.setStaffName(c.getStaff().getFullName());
			purchaseDTOs.add(purchaseOrderDTO);	
		}
		return purchaseDTOs;
	}
	
}
